﻿<System.ComponentModel.DefaultEvent ("StarterSaved")>
Public Class StarterProperties
    Public Class StarterSaveEventArgs
        Inherits System.EventArgs

        Dim FilePathString As String

        Public ReadOnly Property FilePath
            Get
                Return FilePathString
            End Get
        End Property

        Public Sub New(ByVal FileName As String)
            FilePathString = FileName
        End Sub
    End Class
    Private Sub ButtonBrowseFile_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles ButtonBrowseFile.Click
        Dim ofd As New Microsoft.Win32.OpenFileDialog
        Try
            ofd.FileName = TextBoxPath.Text
        Catch ex As Exception

        End Try
        ofd.Filter = "Anwendungen (*.exe)|*.exe|Alle Dateien|*.*"
        ofd.FilterIndex = 1

        If ofd.ShowDialog() = True Then
            TextBoxPath.Text = ofd.FileName
        End If
    End Sub

    Private Sub ButtonSave_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles ButtonSave.Click
        My.Settings.StarterPath = TextBoxPath.Text
        Dim StarterArgs As New StarterSaveEventArgs(TextBoxPath.Text)
        RaiseEvent StarterSaved(Me, StarterArgs)
        Me.Close()
    End Sub

    Public Event StarterSaved(ByVal sender As System.Object, ByVal e As StarterSaveEventArgs)

    Private Sub Button1Cancel_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1Cancel.Click
        Me.Close()
    End Sub

    Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        TextBoxPath.Text = My.Settings.StarterPath
        Me.Background = New SolidColorBrush(SystemColors.ControlColor)
    End Sub

End Class
